package io.jft.doll.wxapi

import android.content.Intent
import android.databinding.ViewDataBinding
import android.os.Bundle
import com.g.base.ui.BaseActivity
import com.tencent.mm.opensdk.modelbase.BaseReq
import com.tencent.mm.opensdk.modelbase.BaseResp
import com.tencent.mm.opensdk.modelpay.PayResp
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler
import io.jft.doll.api.weChatApi
import io.jft.doll.event.WxPayEvent
import org.greenrobot.eventbus.EventBus

/**
 * Created by G on 2017/12/22 0022.
 */
class WXPayEntryActivity : BaseActivity<ViewDataBinding>(), IWXAPIEventHandler {
    override var isDefaultAnim: Boolean = false

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        weChatApi.handleIntent(intent, this)
        overridePendingTransition(0, 0)
    }

    override fun onNewIntent(intent: Intent?) {
        super.onNewIntent(intent)
        setIntent(intent)
        weChatApi.handleIntent(intent, this)
    }

    override fun onResp(resp: BaseResp?) {
        EventBus.getDefault().post(WxPayEvent(resp as PayResp))
        overridePendingTransition(0, 0)
        finish()
    }

    override fun onReq(p0: BaseReq?) {}
}